#include "ConfigManager.h"
#include "TreeManager.h"

namespace PeanutQuest {

	TreeManager::TreeManager(std::string id) : cg::Entity(id) {
	}
	TreeManager::~TreeManager() {
	}

	void TreeManager::init() {

		config = (ConfigManager*)cg::Registry::instance()->get("ConfigManager");

		trees.push_back(new Tree(cg::Vector3f(config->tree1)));
		trees.push_back(new Tree(cg::Vector3f(config->tree2)));
		trees.push_back(new Tree(cg::Vector3f(config->tree3)));
		trees.push_back(new Tree(cg::Vector3f(config->tree4)));
		trees.push_back(new Tree(cg::Vector3f(config->tree5)));
		trees.push_back(new Tree(cg::Vector3f(config->tree6)));
		trees.push_back(new Tree(cg::Vector3f(config->tree7)));
		trees.push_back(new Tree(cg::Vector3f(config->tree8)));
		trees.push_back(new Tree(cg::Vector3f(config->tree9)));
		trees.push_back(new Tree(cg::Vector3f(config->tree10)));

		for(std::vector<Tree*>::iterator it = trees.begin(); it != trees.end(); ++it){
			(*it)->init();
		}

	}

	void TreeManager::update(unsigned long elapsed_millis) {

		for(std::vector<Tree*>::iterator it = trees.begin(); it != trees.end(); ++it){
			//(*it)->update(elapsed_millis);
		}

	}

	void TreeManager::draw() {

		for(std::vector<Tree*>::iterator it = trees.begin(); it != trees.end(); ++it){
			(*it)->draw();
		}

	}

	void TreeManager::deleteTree(Tree* tree) {
		trees.erase(std::remove(trees.begin(), trees.end(), tree), trees.end());
	}

}